package cnki.kg.algorithm;

import org.junit.jupiter.api.Test;

public class HammingDistance {
    @Test
    public void test(){
        int res=hammingDistance(3,6);
    }
    public int hammingDistance(int x, int y) {
       if(x==y&&x==0) return 0;
       int count=0;
       while (x!=0||y!=0){
           if(x%2!=y%2){
               count++;
           }
           x=x/2;
           y=y/2;
       }
       return count;
    }
    @Test
    public void erjinzhishu() {
        int x=6;
        String count="";
        while(x!=0){
            int y=x%2;
            x=x/2;
            count=y+count;
        }
        System.out.println(count);
    }
}
